package com.wsj.a.collapsingdemo;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by linxiujie on 2018/8/3.
 */

public class MyAdapter extends FragmentPagerAdapter {

    public List<Fragment> mFragment = new ArrayList<>();

    public MyAdapter(FragmentManager fm) {
        super(fm);
    }

    @Override
    public Fragment getItem(int position) {
        return mFragment.get(position);
    }

    @Override
    public int getCount() {
        return mFragment.size();
    }

    public void setData(List<Fragment> data){
        if(data != null && data.size()>0){
            mFragment.clear();
            mFragment.addAll(data);
        }
    }

    @Override
    public CharSequence getPageTitle(int position) {
        switch (position){
            case 0:
                return "作品库";
            case 1:
                return  "链接库";
        }
        return "";
    }
}
